import {
  Body,
  ClassSerializerInterceptor,
  Controller,
  HttpCode,
  HttpStatus,
  Post,
  UseInterceptors,
} from '@nestjs/common';
import { AuthService } from '@/modules/auth/auth.service';
import { ApiBody } from '@nestjs/swagger';
import { User } from '@/modules/user/user.entity';

@Controller('auth')
export class AuthController {
  constructor(private readonly authService: AuthService) {}

  /**
   * 用户登录
   * @param user
   */
  @UseInterceptors(ClassSerializerInterceptor)
  @Post('login')
  @HttpCode(HttpStatus.OK)
  @ApiBody({
    type: User,
    description: '登录请求体',
  })
  login(@Body() user) {
    return this.authService.login(user);
  }
}
